$(function() {
	var trObj = $(".confirmPrice table tr:lt(4)");
	$("td:eq(1)", trObj).css("color", "#CCCCCC");
	$("td:eq(2)", trObj).css("color", "#FF0000");
	//相对选择器
	$(".btnSubmit").click(btnSub);
	$("input[name='address']").click(jumpAddress);
	$("td:eq(5) a",trObj).click(isDelete);
	createAddress();
});

function btnSub() {
	alert("购买成功！");
	window.location = "Index.html"
}

function jumpAddress(){
	window.location = "ReceivingAddress.html"
}

function isDelete(){
	if(confirm("你确定要删除吗？")){
		$(this).parent("td").parent("tr").remove();
	}
}
//获取get请求的参数
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if(r != null) return decodeURI(r[2]);
    return null;
}

function createAddress(){
	var address = "", province, city, street, number;
	if(province = GetQueryString("province")){
		address += province;
	}
	if(city = GetQueryString("city")){
		address += " " + city;
	}
	if(street = GetQueryString("street")){
		address += " " + street;
	}
	if(number = GetQueryString("number")){
		address += " " + number;
	}
	$("input[name='address']").val(address);
}
